<?php
include('../include/db-connect.php');

//Build Menu for Categories
$catSql = mysql_query("SELECT category FROM media GROUP BY category ORDER BY category DESC");
echo "<div id=\"accordion\">";
while($row = mysql_fetch_array($catSql))
{
	$category = $row['category'];
	echo "<center><h3>$category</h3></center>\n";
	$titleSql = mysql_query("SELECT title FROM media WHERE category LIKE '$category' GROUP BY title ORDER BY title ASC");
	while($row = mysql_fetch_array($titleSql))
	{
		$title = addslashes($row['title']);
		echo "<ul>$title</ul>\n";
		$fileSql = mysql_query("SELECT * FROM media WHERE category LIKE '$category' and title LIKE '$title' ORDER BY filename ASC");
		while ($row = mysql_fetch_array($fileSql))
		{

			$filename = trim($row['filename']);
			$filename = addslashes($filename);
			$fileId = $row['id'];
//			echo "Id -> $fileId, Filename -> $filename\n";
			echo "<center><a href=\"#\" id=\"$fileId\">$filename</a></center>\n";
		}//End While for $fileSql

	}//End while for $titleSql

}//End While for $catSql
echo "<div>";



?>
